<%@ page language="java" import="java.util.*,com.beans.*,com.dao.*" pageEncoding="UTF-8"%>   
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();  
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>  
<html>
  <head>
    <base href="<%=basePath%>">  
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	
	<meta http-equiv="description" content="This is my page">
	<script type="text/javascript" src="js/jquery-1.8.0.js"></script> 
	<script type="text/javascript">
		$(function(){
			$("#ch_checkall,#top_ch_checkall").click(function(){
				if(this.checked){
					$("input[name=ck_id]").attr("checked","checked");
				}else{
					$("input[name=ck_id]").removeAttr("checked");
				}		
			});
					
			$("table tr").mouseover(function(){
				$(this).css("background","#D3EAEF");
				$(this).siblings().css("background","white");
			});
		});
		
		function bianYe(pageIndex,flag){
			document.form1.action="MemberServlet.do?flag="+flag+"&pageIndex=" + pageIndex;
			document.form1.submit();
		}
		
		function zhuanYe(flag){
			var pageIndex=document.getElementById("pageIndex").value;
			bianYe(pageIndex,flag);
		}
		
		
		function deletemore(pageIndex){
			var list=document.getElementsByName("ck_id");
			var flag=false;
			for(var i=0;i<list.length;i++){
				if(list[i].checked==true){
					flag=true;
				}
			}
			if(flag==true){
				if(confirm("确定要删除吗")){
					var href=$()
					document.form1.action="MemberServlet.do?flag=moredelete&pageIndex=" + pageIndex;
					document.form1.submit();
					return false;/* 让form表单提交进行多个删除   超链接不提交  如果超链接也提交就回提交两次 */
				}else{
					return false;
				}
				
			}else{
				alert("至少选中一个才可以删除");
				return false;
			}
		}
		</script>
		
		<link rel="stylesheet" type="text/css" href="css/maintable.css" ></link>
		<style type="text/css">
			#memberName{
				width:100px;/* 来设定会员账号那一栏固定长度 */
			}
		</style>
		
  </head>
  
  <body>
    <div class ="div_title">
		<div class="div_titlename"> <img src="images/san_jiao.gif" ><span>商品列表</span></div>
		<div class="div_titleoper">
			<input type="checkbox" id="top_ch_checkall"/> 全选  <a href="MemberServlet.do?flag=moredelete" onclick="return deletemore('${pageInfo.pageIndex}')"><img src="images/del.gif"/>删除</a> </div>
		</div>
		<form action="MemberServlet.do"  name="form1" method="post">
		会员账号: <input type="text" name="memberNoCha" value="${param.memberNoCha }"/>
		注册日期从: <input type="date" name="dateBegin" value="${param.dateBegin }"/>
		到: <input type="date" name="dateEnd" value="${param.dateEnd }"/>
		<input type="hidden" name="flag" value="tiaojan">
		<input type="submit" value="查询" onclick="return confirm('确认查询码')">
		 <table class="main_table" >
		       <tr>
		 				<th><input type="checkbox" id="ch_checkall" /></th>	<th id="memberName">账号</th> 	<th>姓名</th>	<th>电话</th>  <th>邮箱</th>  <th>注册日期</th> <th>会员等级</th>	<th>操作</th>
		 		</tr>
		 		<c:forEach var="member" items="${ memberInfo}">
		 			<tr>
		 				<td><input type="checkbox" name="ck_id" value="${ member.id}" /> </td>
		 				<td >${member.memberNo }</td>
		 				<td>
		 					${member.memberName }
		 				</td>
		 				<td >${member.phone }</td>
		 				<td >${member.email }</td>
		 				<td >${member.registerDate }</td>
		 				<td >${member.memberLevel }</td>
		 				<td>
			 				<a href="MemberServlet.do?flag=selectMember&id=${member.id}" >查看</a> |  
		 			    	<a href="MemberServlet.do?flag=deletemember&id=${member.id}&pageIndex=${pageInfo.pageIndex }" onclick="return confirm('确认要删除吗')">删除</a> |  
			 			</td>
		 			</tr>
		 		</c:forEach>
		</table>
		</form>
		
		<div class="div_page" >
			  <div class="div_page_left">    共有 <label>${pageInfo.rowCount }</label> 条记录，当前第 <label>${pageInfo.pageIndex }</label> 页，共 <label>${pageInfo.pageCount }</label> 页	</div>		
			  <div class="div_page_right" > 	 
			  		<c:choose>
				  		<c:when test="${pageInfo.hasPre }">
				  			<input type="submit" value="首页" onclick="bianYe(1,'${flag}')"/>
				  			<input type="submit" value="上一页" onclick="bianYe(${pageInfo.pageIndex-1 },'${flag}')"/>
				  			
				  		</c:when>
				  		<c:otherwise>
				  			首页  上一页
				  		</c:otherwise>
				  	</c:choose>
				  	<c:choose>
				  		<c:when test="${pageInfo.hasNext }">
				  			<input type="submit" value="下一页" onclick="bianYe(${pageInfo.pageIndex+1 },'${flag}')"/>
				  			<input type="submit" value="尾页" onclick="bianYe(${pageInfo.pageCount },'${flag}')"/>
				  		</c:when>
				  		<c:otherwise>
				  			下一页 尾页
				  		</c:otherwise>
				  	</c:choose>
					<input type="submit" value="转到" onclick="zhuanYe('${flag}')">
			  		<input type="text" name="pageIndex" id="pageIndex" name="pageIndex" value="${pageInfo.pageIndex }" /> 页
			  	
			   </div>
		</div>
		<script >
			var t="${msg}";
			if(t!=""){
				alert(t);
			}
		</script>
  </body>
</html>